<?php
require_once '../common.php';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xHTML11/DTD/xHTML11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <?php
    $query_names = $_REQUEST['geneNames'];
    $epsilon_neg = $_REQUEST['e_neg'];
    $pvalue_neg = $_REQUEST['p_neg'];
    $epsilon_pos = $_REQUEST['e_pos'];
    $pvalue_pos = $_REQUEST['p_pos'];
    $rvalue = $_REQUEST['rvalue'];
    $query_type = $_REQUEST['query_type'];
    $tishi = array(
        'Search for interactions between given genes and their first neighbors'
        , 'Search for genetic interactions strictly within given genes'
        , 'Search genetic interactions in biclustering background'
        , 'Cluster genetic interaction profiles'
        , 'Enrichment test for genes'
    );

    if (in_array($query_names, $tishi)) {
        $query_names = '';
    } else {
        $query_names .= ' ';
    }
    if ($_FILES["file"]["error"] > 0) {
        echo "Error: " . $_FILES["file"]["error"] . "<br />";
    } else {
        if (!is_null($_FILES["file"])) {
            $file = fopen($_FILES['file']['tmp_name'], 'r');
            while (!feof($file)) {
                $tmp_str = trim(fgets($file));
                if (strlen($tmp_str) == 0 || is_null($tmp_str))
                    continue;
                $query_names .= ($tmp_str . ' ');
            }
        }
    }
    ?>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Search Result</title> 
        <link rel="stylesheet" type="text/css" href="<?php echo SITEURI; ?>/inc/style/layout-default-latest.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo SITEURI; ?>/inc/style/sgastyle.css" />
        <style type="text/css">
            /* neutralize pane formatting BEFORE loading UI Theme */
            .ui-layout-pane ,
            .ui-layout-content {
                background:    none;
                border:        0;
                padding:    0;
                overflow:    visible;
            }
        </style>
        <link rel="stylesheet" type="text/css" href="<?php echo SITEURI; ?>/inc/style/jquery.ui.all.css" />
        <style type="text/css">
            p               {margin: 1em 0;}
            .grey           {background: #999 !important;}
            .outline        {/*border: 1px dashed #F00 !important;*/}
            .add-padding    {padding: 10px !important;}
            .no-padding     {padding: 0 !important;}
            .add-scrollbar  {overflow: auto;}
            .no-scrollbar   {overflow: hidden;}
            .allow-overflow {overflow: visible;}
            .full-height    {height: 100%;}
            button          {cursor: pointer;}
        </style>
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/lib/jquery-1.6.1.min.js"></script> 
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/lib/jquery-ui-1.8.17.custom.min.js"></script> 
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/lib/jquery.layout-latest.js"></script>
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/lib/jquery.layout.callbacks.min-latest.js"></script>
        <script type="text/javascript"> 
            $(document).ready(function () {
                pageLayout = $("body").layout({
                      west__size:           .35
                    , south__resizable:     false
                    , south__closable:      false
                    , west__onresize:       $.layout.callbacks.resizePaneAccordions
                });
                
                // TABS INSIDE EAST-PANE
                pageLayout.panes.west.tabs({
                    show:       $.layout.callbacks.resizePaneAccordions
                });
                
                $("#accordion-west")    .accordion({ fillSpace: true });
                var query_names = '<?php echo $query_names ?>';
                var epsilon_neg = '<?php echo $epsilon_neg ?>';
                var pvalue_neg = '<?php echo $pvalue_neg ?>';
                var epsilon_pos = '<?php echo $epsilon_pos ?>';
                var pvalue_pos = '<?php echo $pvalue_pos ?>';
                var rvalue = '<?php echo $rvalue ?>';
                var query_type = '<?php echo $query_type ?>';
                var init_view = 'tv';
                var init_type = 'n';
                $('ul#topnav li#table_view').addClass('ui-state-active');
//                showResultView(query_names, epsilon_neg, pvalue_neg, epsilon_pos, pvalue_pos, rvalue, init_view, init_type, query_type);
                $('ul#topnav li#tab_feedback').live('click', function(e){
                    $('#topmenu .ui-state-active').removeClass('ui-state-active');
                    $('ul#topnav li#tab_feedback').addClass('ui-state-active');
                    $('#tabs-west li#tab-genes-selector').hide();
                    $('#tabs-west li#tab-network-selector').hide();
                    $("#tab-annotations-selector a").trigger("click");
                    $('#result_container').hide();
                    $('#feedback').show();
                    showFeedback();
                });
                $('ul#topnav li a.view').live('click', function(e){
                    var target = $(e.target).closest('a.view');
                    var view = target.attr('id').split("_")[0];    // tv(Table View) or nv(Network View);
                    var type = target.attr('id').split("_")[1];    // Type of result.
                    $('#topmenu .ui-state-active').removeClass('ui-state-active');
                    if (view == 'tv'){
                        $('ul#topnav li#table_view').addClass('ui-state-active');
                    } else if (view == 'nv'){
                        $('ul#topnav li#nw_view').addClass('ui-state-active');
                    }
                    $('#tabs-west li#tab-genes-selector').show();
                    $("#tab-genes-selector a").trigger("click");
                    if (view == 'nv' && type == 'i'){
                        $('#tabs-west li#tab-network-selector').show();
                    } else {
                        $('#tabs-west li#tab-network-selector').hide();
                    }
                    showResultView(query_names, epsilon_neg, pvalue_neg, epsilon_pos, pvalue_pos, rvalue, view, type, query_type);
                })
            });
                
        </script> 
    </head> 
    <body> 
        <div id="tabs-west" class="ui-layout-west no-padding no-scrollbar">
            <ul class="allow-overflow">
                <li id="tab-genes-selector"><a href="#tab-panel-west-1">Genes</a></li>
                <li id="tab-network-selector" style='display:none;'><a href="#tab-panel-west-2">Networks</a></li>
                <li id="tab-annotations-selector"><a href="#tab-panel-west-3">Annotations</a></li>
                <li id="tab-analysis-selector"><a href="#tab-panel-west-4">Analysis</a></li>
            </ul>
            <div class="ui-layout-content ui-widget-content no-scrollbar" style="border-top: 0;">
                <div id="tab-panel-west-1" class="full-height no-padding add-scrollbar">
                    <div class="ui-tabs-panel outline">
                        <div class="sidebar1" id="sidebar1"><div class="loading" id="loading" style="display: none;"></div></div>
                    </div>
                </div>
                <div id="tab-panel-west-2" class="full-height no-padding add-scrollbar">
                    <div class="ui-tabs-panel outline"></div>
                </div>
                <div id="tab-panel-west-3" class="full-height no-padding no-scrollbar">
                    <div id="accordion-west" class="full-height">
                        <h3><a href="#">Gene Ontology</a></h3>
                        <div><p></p></div>
                        <h3><a href="#">Human Disease Ontology</a></h3>
                        <div><p></p></div>
                        <h3><a href="#">Kegg Pathway</a></h3>
                        <div><p></p></div>
                        <h3><a href="#">Protein Complex</a></h3>
                        <div><p></p></div>
                    </div>
                </div>
                <div id="tab-panel-west-4" class="full-height no-padding add-scrollbar">
                    <div class="ui-tabs-panel outline"></div>
                </div>
            </div>
        </div>

        <div id="tabs-center" class="ui-layout-center no-padding">
            <div class="content">
                <div class="topmenu" id="topmenu">
                    <ul id="topnav">
                        <li id="table_view" class="ui-state-default ui-corner-top ui-tabs-selected">
                            <a href="javascript:void(0)">Table View</a>
                            <span>
                                <a class="view" id="tv_n" href="javascript:void(0)">Negative Interaction</a> |
                                <a class="view" id="tv_p" href="javascript:void(0)">Positive Interaction</a> |
                                <a class="view" id="tv_c" href="javascript:void(0)">Correlation</a>
                            </span>
                        </li>
                        <li id="nw_view" class="ui-state-default ui-corner-top ui-tabs-selected">
                            <a href="javascript:void(0)">Network View</a>
                            <span>
                                <a class="view" id="nv_i" href="javascript:void(0)">Interaction</a> |
                                <a class="view" id="nv_c" href="javascript:void(0)">Correlation</a>
                            </span>
                        </li>
                        <li class="ui-state-default ui-corner-top ui-tabs-selected"><a href="http://franklin-umh.cs.umn.edu/cellmap/">Back To Home</a></li>
                        <li id="tab_feedback" class="ui-state-default ui-corner-top ui-tabs-selected"><a href="javascript:void(0)">FeedBack</a></li>
                    </ul>
                </div>
                <div class="result_container" id="result_container" style="display: none;">
                    <div class="loading" id="loading" style="display: none;"></div>
                </div>
                <div class="feedback" id="feedback" style="display:none;">
                    <strong class="feedback_title">Feedback: </strong><br />
                    <textarea class="feedback_comment" id="feedback_comment"></textarea><br />
                    <strong class="feedback_title">Name: </strong>
                    <input class="feedback_name" id="feedback_name" type="text"></input>
                    <input class="feedback_submit" id="feedback_submit" type="button" value="Submit"></input><br />
                    <table class="feedback_table" id="feedback_table" border="0" bgcolor="white" cellSpacing="1" cellpadding="5" width="750px" style="table-layout:fixed;">
                        <thead>
                            <tr bgcolor="#9999FF"><th width="500px" align="center">Comment</th><th width="100px" align="center">Name</th><th width="150px">Is Solved</th></tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <div id="ui-copyright" class="ui-layout-south ui-widget-content add-padding">
        </div>
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/lib/jquery.cookie.js"></script>
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/lib/jquery.hotkeys.js"></script>
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/lib/jquery.jstree.js"></script>
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/lib/json2.min.js"></script>
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/lib/AC_OETags.min.js"></script>
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/lib/cytoscapeweb.min.js"></script>
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/lib/lhgdialog.min.js"></script>
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/sga.js"></script>
    </body> 
</html>
